What's that for? Ok, imagine the following situation. You use the applet as a menubar in the left frame. This applet links to the miscellaneous pages of your site, and you have set the BUTTONSTAYPRESSED parameter, i.e. the button clicked last stays pressed to indicate where on your site the viewer is. But what if the applet is not the only way to navigate thru your site? Perhaps you have a link to a different section in the mainframe. If the viewer clicks on such a link the buttonbar applet won't change, since it does not know the mainframe contains another page now. The pressed button would indicate a false section.
Therefore you can force the applet to change the pressed button with this JavaScript:
<script language="JavaScript">
<!--
function myLink(NewLocation,
ButtonNumber) {
parent.buttonbarframe.document.buttonbarapplet.setNewPressedButton(ButtonNumber);
parent.buttonbarmainframe.document.location.href
= NewLocation;
}
//-->
</script>
Just copy-paste it into the head section of the HTML document which contains the link. This is what the script makes:
The line
parent.buttonbarframe.document.buttonbarapplet.setNewPressedButton(ButtonNumber);
means: call the method named "setNewPressedButton()" of the applet named "buttonbarapplet" in the frame named "buttonbarframe". The method called "setNewPressedButton" must know the number of the new pressed button, therefore it is given a parameter with the number. Of course the names of the frames must be specified in the frameset definition and you'll have to insert "name=buttonbarapplet" into the "<applet ...>" tag.
The line
parent.buttonbarmainframe.document.location.href = NewLocation;
means: display the document the name of which is stored in the string named "NewLocation" in the frame called "buttonbarmainframe".
Now the link itself: instead of just making an ordinary link you create your links from now on this way:
<a href="javascript:myLink('buttonbar_examples.html',4)">Testlink</a>
This means: when this link is clicked, execute the JavaScript function called "myLink" and give it the parameters "buttonbar_examples.html" and "4". The first parameter is the HTML file which shall be displayed and the second one defines the button which shall be pressed. That's all.
Here's an example - if you click on the following link the main page will appear and the pressed button in the left frame will also change: